home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Games of Daze
/
Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso
/
x2ftp
/
msdos
/
ai
/
fuzzy
/
token.s
< prev
Wrap
Text File
|
1986-11-29
|
5KB
|
85 lines
-------------------------------------------------------------------------------
-- --
-- Library Unit: Token -- Get token package --
-- --
-- Author: Bradley L. Richards --
-- --
-- Version Date Notes . . . --
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --
-- 1.0 6 Feb 86 Initial Version --
-- 1.1 25 Feb 86 All basic routines completed --
-- 1.2 13 Mar 86 Added reserved words. Split Ada and Fuzzy --
-- Prolog via conditional compilation --
-- 1.3 22 May 86 Revised lots of Fuzzy Prolog stuff to make it --
-- work; adding reserved words, etc.. --
-- 1.4 19 Jun 86 Use revised io package and data_def --
-- 2.0 20 Jun 86 Token_type extracted into package Data_def --
-- 2.05 13 Jul 86 Split into separate spec and body files --
-- 2.1 21 Jul 86 Demonstration Version --
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --
-- --
-- Library units used: io -- read source file and produce listing --
-- listing -- insert messages in listing --
-- data_def -- common data definitions --
-- --
-- Description: This package reads the source file (via "io") and parses --
-- out individual tokens. There are three defined types which calling --
-- routines must use. Token_type defines the legal kinds of tokens --
-- which may be returned. Token_record is a variant record (with a --
-- discriminant of token_type) which is used to hold tokens. Finally, --
-- token_ptr is the access type to the dynamically allocated --
-- token_records. --
-- This package must be initialized by calling start_token. Then --
-- subsequent calls to get_token will return one token each. Note --
-- that end-of-file is indicated by the special token "end_of_file." --
-- --
-- Note that this package is designed to be used with multiple --
-- languages. In order to share the code and ensure that generic --
-- changes are made to all versions, this package is kept in a master --
-- source file which contains conditional compilation directives --
-- for use by the Ada preprocessor "pp." --
-- --
-------------------------------------------------------------------------------
-- --
-- Package Specification --
-- --
-------------------------------------------------------------------------------
with data_def, io, listing; use data_def, io, listing;
package token is
--
-- define the record and access types for tokens
--
type token_record (is_a : token_type) is
record
case is_a is
when identifier => ident_name : name_ptr;
when variable => var_name : name_ptr;
when reserved_word => word : token_type;
when float_num => fp_num : float;
when integer_num => int_num : integer;
when character_lit => char : character;
--
-- all other token types require no data other than the discriminant
--
when others => null;
end case;
end record;
type token_ptr is access token_record;
current_token : token_ptr;
unexpected_end_of_file : exception;
procedure get_token;
procedure start_token(source_file, listing_file : in string);
procedure stop_token;
private
procedure skip_rest_of_token;
function valid_ending( char : character ) return boolean;
end token;